package com.ah.shanxi_demo.sync.convert;

import com.ah.shanxi_demo.entity.SxRegister;
import com.ah.shanxi_demo.sync.param.PolicyDataReportPO;
import com.ah.shanxi_demo.sync.param.result.SyncReceiptResult;
import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zt 2020/8/15
 */
public class ConvertSyncParam {

    /**
     * 注册接口 参数拼装
     *
     * @return
     */
    public static Map<String, Object> convert_sync_register(SxRegister sxRegister) {

        Map<String, Object> paramsMap = new HashMap<>();
        paramsMap.put("parent_center_code", sxRegister.getParentCenterCode());
        paramsMap.put("center_code", sxRegister.getCenterCode());
        paramsMap.put("center_name", sxRegister.getCenterName());
        paramsMap.put("ip", sxRegister.getIp());
        paramsMap.put("geoloc", sxRegister.getGeoloc());
        return paramsMap;
    }

    /**
     * 同步接口 参数拼装
     *
     * @return
     */
    public static Map<String, Object> convert_sync_sync(SxRegister sxRegister) {

        Map<String, Object> paramsMap = new HashMap<>();
        paramsMap.put("center_code", sxRegister.getCenterCode());
        paramsMap.put("center_key", sxRegister.getCenterKey());
        return paramsMap;
    }

    /**
     * 生成策略接口 参数拼装
     *
     * @return
     */
    public static Map<String, Object> convert_sync_policy(SxRegister sxRegister) {

        Map<String, Object> paramsMap = new HashMap<>();
        paramsMap.put("center_code", sxRegister.getCenterCode());
        paramsMap.put("center_key", sxRegister.getCenterKey());
        return paramsMap;
    }

    /**
     * 策略数据采集接口 参数拼装
     *
     * @return
     */
    public static Map<String, Object> convert_sync_policy_data(PolicyDataReportPO policyDataReportPO) {

        Map<String, Object> paramsMap = JSONObject.parseObject(JSONObject.toJSONString(policyDataReportPO), Map.class);

        if (paramsMap==null){
            return new HashMap<>();
        }
        return paramsMap;
    }

    /**
     * 生成工单接口 参数拼装
     *
     * @return
     */
    public static Map<String, Object> convert_sync_order(SxRegister sxRegister) {

        Map<String, Object> paramsMap = new HashMap<>();
        paramsMap.put("center_code", sxRegister.getCenterCode());
        paramsMap.put("center_key", sxRegister.getCenterKey());
        return paramsMap;
    }

    /**
     * 工单回执接口 参数拼装
     *
     * @return
     */
    public static Map<String, Object> convert_sync_receipt(SyncReceiptResult syncReceiptResult) {

        Map<String, Object> paramsMap = new HashMap<>();
        paramsMap.put("center_code", syncReceiptResult.getCenter_code());
        paramsMap.put("center_key", syncReceiptResult.getCenter_key());
        paramsMap.put("work_code", syncReceiptResult.getWork_code());
        paramsMap.put("accdept", syncReceiptResult.getAccdept());
        paramsMap.put("accuser", syncReceiptResult.getAccuser());
        paramsMap.put("phone", syncReceiptResult.getPhone());
        paramsMap.put("write_user", syncReceiptResult.getWrite_user());
        paramsMap.put("content", syncReceiptResult.getContent());
        paramsMap.put("attach_flag", syncReceiptResult.getAttach_flag());
        paramsMap.put("attach_name", syncReceiptResult.getAttach_name());
        paramsMap.put("attach_content", syncReceiptResult.getAttach_content());
        return paramsMap;
    }

}
